/*
 * BaseParser.h
 *
 *  Created on: Nov 1, 2011
 *      Author: zwx
 */

#ifndef BASEPARSER_H_
#define BASEPARSER_H_
#include "../Include/includes.h"
using namespace std;

struct doc {
	size_t id;
	string name;
	double score;
	list<size_t> pos;
	bool operator <(const doc& a) const {
		return score > a.score;
	}
};

struct doc_entry {
	size_t doc_id;
	size_t pos_count;
	list<size_t> pos_list;
};

struct posting {
	string term;
	size_t term_id;
	size_t doc_count;
	size_t offset;
	size_t barrel_no;
	list<struct doc_entry> entry;
};

class BaseParser {
protected:
	static const int MAX_TOKEN_NUM = 5;
	static const int MAX_LINE_SIZE = 1048576;
	void get_postings(struct posting& );
	void extract_posting_info(char* , struct posting& );
	int divide_query(char* , char** );
	void load_term_info(char** , struct posting* , int );
	void get_doc_name(list<struct doc>*);
public:
	BaseParser();
	virtual ~BaseParser();

};

#endif /* BASEPARSER_H_ */
